package com.youmu.maven.emall.service.support;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.youmu.maven.emall.dao.BaseDao;
import com.youmu.maven.emall.entity.BaseEntity;

public class BaseService {

	public Map<String, Object> initParam(BaseEntity entity) {
		Map<String, Object> parameter = new HashMap<String, Object>();
		parameter.put(BaseDao.PARAMETERS_KEY, entity);
		return parameter;
	}

	public BaseEntity getOne(List<? extends BaseEntity> list,
			boolean throwException) {
		if (list != null && list.size() == 1)
			return list.get(0);
		if (list == null || list.size() == 0)
			return null;
		if (list != null && list.size() > 1) {
			if (throwException)
				throw new RuntimeException("多个内容");
			else
				return list.get(0);
		}
		return null;
	}
}
